#ifndef SSLBASE_H
#define SSLBASE_H

#include <defs/export.h>
#include <defs/global.h>

#include <core/entityobject.h>
#include <QtCore>
#include <QUrl>
#include <QSettings>
#include <log4qt/logger.h>
#include "common.h"

namespace Opl
{
	namespace Helpers
	{
		namespace Ssl
		{
			O_PRIVATE_DECLARE(SslBase);
			class HELPERS_EXPORT SslBase : public Opl::Core::EntityObject
			{
					Q_OBJECT
					LOG4QT_DECLARE_QCLASS_LOGGER
				public:

					SslBase(QSslSocket* socket = 0);
					virtual ~SslBase();

					Opl::Helpers::ConnectionStatus status()const;

				public slots:
					virtual void start();
					virtual void stop();
					void Send(const QString& data);

				private slots:
					void ready();
					void sslErrors(const QList<QSslError>& errors);
					void modeChanged (QSslSocket::SslMode mode);
					void peerVerifyError (const QSslError& error);
					void socketConnected();
					void socketDisconnected();
					void error(QAbstractSocket::SocketError socketError);
					void hostFound();
					void proxyAuthenticationRequired (const QNetworkProxy& proxy, QAuthenticator* authenticator);
					void stateChanged(QAbstractSocket::SocketState socketState);
					void readyCommand();

				signals:
					void connected();
					void disconnected();
					void error();
					void output(const QString& data);

				protected:
					void setSocket(QSslSocket* s);
					QSslSocket* socket()const;

					void setStatusInternal(Opl::Helpers::ConnectionStatus s);

				private:
					O_PRIVATE_DECLARE_MEMBER(SslBase);
			};

		}
	}
}
#endif // SSLBASE_H

